var moment = require('moment');
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var Common = require('../util/common');

var Tag = new Schema({
  author: {
    type: Schema.Types.ObjectId,
    ref: "User"
  },
  article:{
    type: Schema.Types.ObjectId,
    ref: "Article"
  },
  
  name: {
    type: String,
    default: ''
  },
  description: {
	type: String,
	default: ''
  },
  coverplan: {
	type: String,
	default: ''
  },
  
  created: {
    type: Date,
    default: moment().utc().format()
  },
  lastmod: {
    type: Date,
    default: moment().utc().format()
  }
});

Tag.pre("save", function(next) {
  this.lastmod = moment().utc().format();
  next();
});

exports.Tag = mongoose.model("Tag", Tag);
